Skip to content

fix(amazonq): Addition of wait function for Amazon Q inline chat UI E2E Tests and Inline Keybind Shortcut Test #7840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Aug 15, 2025

Conversation

surajrdy-aws
Copy link

@surajrdy-aws surajrdy-aws commented Aug 7, 2025

Problem

Currently we use a sleep(8000) function which causes us to wait an arbitrary 8 seconds for Amazon Q to implement the fibonacci sequence. This can cause flakiness and is generally not a good practice. We also have not fully updated our inline test and our writeToTextEditor function does not work well. We also have not implemented an inline test which uses keybinds to start an inline chat suggestion.

Solution

I have implemented a function which constantly checks for a "stable" state in which we check for any new number of lines generated by Amazon Q. If this stable state is repeated more than 2 times, meaning the number of lines has stayed the same for 3 seconds (1 second wait in between), we will confirm that AmazonQ has finished generating its response. We have a maximum generate time of 15 seconds, as a fibonacci sequence should not take more than that, or something is clearly wrong with the model and we will error out. We have implemented the inline tests and the writeToTextEditor function fix.


  • Treat all work as PUBLIC. Private feature/x branches will not be squash-merged at release time.
  • Your code changes must meet the guidelines in CONTRIBUTING.md.
  • License: I confirm that my contribution is made under the terms of the Apache 2.0 license.

@surajrdy-aws surajrdy-aws requested a review from a team as a code owner August 7, 2025 19:41
Copy link

github-actions bot commented Aug 7, 2025

  • This pull request implements a feat or fix, so it must include a changelog entry (unless the fix is for an unreleased feature). Review the changelog guidelines.
    • Note: beta or "experiment" features that have active users should announce fixes in the changelog.
    • If this is not a feature or fix, use an appropriate type from the title guidelines. For example, telemetry-only changes should use the telemetry type.

it('Inline Test', async () => {
await writeToTextEditor(textEditor, 'Select Me')
after(async function () {
// Switch back to Webview Iframe when dealing with external webviews from Amazon Q.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be corrected to iframe

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha!

* @returns Promise<void>
* @throws Error if timeout is exceeded
*/
export async function waitForEditorStabilization(editor: TextEditor, timeout = 15000): Promise<void> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a better name for this function? edtior stabilization sounds a bit unclear to me, maybe something like waitForTextGeneration is better?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!


if (currentLines === previousLines) {
stableCount++
if (stableCount >= 2) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whats the logic for breaking when stableCount is >= 2? does that mean that as soon as we see more then 2 lines we break?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, this essentially will check for if the number of lines has not changed yet. If this number of lines being the same occurs twice (requiring another sleep), then we can say that the model has stopped generating code or thinking. Although it might be more useful to say this is just greater than 2, rather than equal to 2.

Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small doc comment, otherwise lgtm.

const text = await textEditor.getText()
assert.equal(text, 'Select Me')
assert.equal(text, 'def factorial(n): ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a silly question, but why does this pass with the space at the end, if the writeToTextEditor above doesn't add a space at the end? Or does it automatically?

Is this related to the dummy space below?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! The dummy space actually creates a space at the end of the word, and then it types from before that space so the space ends up at the end of whatever text we generate. I actually removed this logic since it is no longer needed in the test (the assert equal text)

}

/**
* Waits for Inline Generation by Amazon Q by checking if line count stops changing
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I like the logic you decided on here. Might be worth summarizing this logic in the doc-string since it would not be obvious to me without reading your PR description. (Nice PR description btw!)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Will do.

@surajrdy-aws surajrdy-aws changed the title fix(amazonq): Addition of wait function for Amazon Q inline chat UI E2E Tests fix(amazonq): Addition of wait function for Amazon Q inline chat UI E2E Tests and Inline Keybind Shortcut Test Aug 11, 2025
@Hweinstock
Copy link
Contributor

Looks like a lint error:

test/e2e_new/amazonq/utils/generalUtils.ts(218,1): error TS1005: '}' expected.

Fix lint issue with writeToTextEditor
Copy link
Contributor

@Hweinstock Hweinstock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!

@laura-codess
Copy link

One required macOS test is failing, should retry that and then I'll send the approve 👍

@bywang56 bywang56 merged commit 40ce504 into aws:feature/ui-e2e-tests Aug 15, 2025
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants